#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

int add(char *num1_start, char *num1_end, char *num2_start, 
    char *num2_end, char *result, int flag)
{
    char num1, num2; 

    assert(num1_start !=  NULL);    
    assert(num1_end !=  NULL);    
    assert(num2_start !=  NULL);    
    assert(num2_end !=  NULL);    
    assert(result !=  NULL);    

    num1 = *num1_end;
    num2 = *num2_end;
    while (num1_end > num1_start-1)
    {
        assert(isdigit(num1));
        assert(isdigit(num2));

        *result += (num1 - '0' + num2 - '0' + flag)%10;
        flag = (num1 - '0' + num2 - '0' + flag)/10;

        result --;

        num1_end--;
        num1 = *num1_end;

        if (num2_end != num2_start)
        {
            num2_end --;
            num2 = *num2_end;
        }
        else
            num2 = '0';
    }

    return flag;
}

int main(int argc, char *argv[])
{
    char *index1, *index2, *result;
    int len1, len2, zlen1, zlen2, xlen1, xlen2, len3, zlen3, xlen3;

    if (argc != 3)
    {
        printf("usage: %s <num1><num2>\n", argv[0]);
        exit(0);
    }

    len1 = strlen(argv[1]);
    len2 = strlen(argv[2]);

    index1 = index(argv[1], '.');
    index2 = index(argv[2], '.');

    if (index1 == NULL)
    {
        index1 = argv[1]+len1;
        zlen1 = len1;
        xlen1 = 0;
    }
    else
    {
        xlen1 = strlen(index1)-1;
        zlen1 = len1 - xlen1 - 1;
    }

    if (index2 == NULL)
    {
        index2 = argv[2]+len2;
        zlen2 = len2;
        xlen2 = 0;
    }
    else
    {
        xlen2 = strlen(index2)-1;
        zlen2 = len2 - xlen2 - 1;
    }

    zlen3 = (zlen1>zlen2?zlen1:zlen2) + 1;
    xlen3 = (xlen1>xlen2?xlen1:xlen2) + 1;
    len3 = zlen3+xlen3;
    result = malloc(len3+1);
    memset(result, '0', len3);
    result[len3] = '\0';

    int nlen = xlen1>xlen2?xlen2:xlen1;
    char *num1_start, *num2_start, *num1_end, *num2_end;
    if (zlen1 > zlen2)
    {
        num1_start = argv[1];
        num1_end = index1-1;
        num2_start = argv[2];
        num2_end = index2-1;
    }
    else
    {
        num1_start = argv[2];
        num1_end = index2-1;
        num2_start = argv[1];
        num2_end = index1-1;
    }

    if (add(num1_start, num1_end, num2_start, num2_end, result+zlen3-1, 
            add(index1+1, index1+nlen, index2+1, index2+nlen,
                result+zlen3+nlen, 0)) > 0)
        result[0] ++;

    if (xlen3 == 1)
    {
        result[zlen3] = '\0';
    }
    else
    {
        result[zlen3] = '.';
        if (xlen1 > xlen2)
            strcpy(result+zlen3+nlen+1, index1+nlen+1);
        else
            strcpy(result+zlen3+nlen+1, index2+nlen+1);
    }

    int i;
    for (i = 0; i < zlen3-1; i++)
        if (result[i] != '0')
            break;

    printf("%s\n", &result[i]);
    free(result);

    return 0;
}


